/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.app.service.impl;

import java.util.List;
import org.app.dto.google.ResponseDataJson;
import org.app.dto.google.Results;
import org.app.model.QueueURLs;
import org.app.service.GoogleService;
import org.app.service.SearchService;
import org.app.utils.PropertiesHelper;
import org.app.utils.PropertyUtils;
import org.app.utils.Utils;
import org.gui.AutoDownloadMovieGUI;

/**
 *
 * @author LamLe
 */
public class SearchServiceImpl implements SearchService {

    AutoDownloadMovieGUI main;
    GoogleService googleService;

    public SearchServiceImpl(AutoDownloadMovieGUI main) {
        this.main = main;
    }

    private void log(String str) {
        main.write(str);
    }

    @Override
    public void searchMovie(String movieName) throws Exception {
        try {
            if (!movieName.equals("")) {
                // now using google api service version 1
                if (PropertyUtils.getProperty(PropertiesHelper.VERSION).equals("1")) { // Use Google search API
                    googleService = new GoogleAPI_ServiceImpl(main);
                } else if (PropertyUtils.getProperty(PropertiesHelper.VERSION).equals("2")) { // Use browser request Google disable javascript
                    googleService = new GoogleDisableJS_ServiceImpl(main);
                }
                googleService.search24(movieName);
            } else {
                log("Sorry please enter movie name");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
